/*
 * Copyright (c) 2006-2020, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-05-21     chenhy       the first version
 */
#include "board.h"
#include "iwdg.h"

IWDG_HandleTypeDef hiwdg;

int iwdg_init(void)
{
  hiwdg.Instance = IWDG;
  hiwdg.Init.Window = IWDG_WINDOW_DISABLE;
  hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
  hiwdg.Init.Reload = 0xC35;
  HAL_IWDG_Init(&hiwdg);
  iwdg_feed();
  return 0;
}

void iwdg_feed(void)
{
  HAL_IWDG_Refresh(&hiwdg);
}
